package com.example.javascaffold.utils;



import com.example.javascaffold.constant.Constant;
import com.example.javascaffold.model.dto.BaseDTO;

import java.util.Map;


/**
 * <p><strong>分页查询工具类</strong></p>
 * <p>(已封装进 @PageQuery)</p>
 * <li>
 * <p>
 *     <strong>示例1: 分页</strong> <br>
 *     baseDTO = PageParamUtils.makePaging(baseDTO);
 * </p>
 * </li>
 * @author song
 *
 * @see Integer
 * @see Map
 * @see Constant
 * @see CheckParamUtils
 * @since 10:02 2021/5/30
 **/
public class PageParamUtils {

    private PageParamUtils() {}

    /**
     * <li>
     * <p>
     *     <strong>示例1: 分页</strong> <br>
     *     baseDTO = PageParamUtils.makePaging(baseDTO);
     * </p>
     * </li>
    **/
    public static void checkPage(BaseDTO baseDTO) {
        if (CheckParamUtils.isNullOrEmpty(baseDTO.getPage()) || baseDTO.getPage() <= 0) {
            // page不存在 是否0
            //
            baseDTO.setPage(Constant.DEFAULT_PAGE);
        }
        if (CheckParamUtils.isNullOrEmpty(baseDTO.getLimit()) || baseDTO.getLimit() <= 0) {
            // limit不存在 是否0
            baseDTO.setLimit(Constant.DEFAULT_LIMIT);
        }
    }
}
